package cn.pengpeng.hive.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestJdbc {
	/**
	 * 测试执行成功
	 * @param args
	 * @throws ClassNotFoundException
	 * @throws SQLException
	 */
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		
		String driver = "org.apache.hive.jdbc.HiveDriver";
		String url = "jdbc:hive2://bigdata01:10000";
		String username = "root";
		String passwd = "";
		
		Class.forName(driver);
		Connection connection = DriverManager.getConnection(url, username, passwd);
		Statement statement = connection.createStatement();
		ResultSet resultSet = statement.executeQuery("select count(*) from t_order");
		while(resultSet.next()){
			String id = resultSet.getString(1);
			System.out.println(id);
		}
		resultSet.close();
		statement.close();
		connection.close();
		
	}

}
